import java.util.Scanner;

public class Polynomial {

	static void outputItem(int coeff, int exp, boolean hidePlus) {
		
		String x = String.format("%+dx%d", coeff, exp);
		
		if (coeff == -1 || coeff == 1) {
			x = x.replace("1x", "x");
		}
		if (exp == 1) {
			x = x.replace("x1", "x");
		}
		if (hidePlus) {
			x = x.replace("+", "");
		}
		System.out.print(x);

	}
	public static void main(String[] args) {
		
		int [] coefficient = new int [101];
		
		Scanner in = new Scanner(System.in);
		
		int nPolynomial = 1;
		int exp = 0;
		int coeff = 0;
		int maxExp = 0;

		do {
			exp = in.nextInt();
			coeff = in.nextInt();
			coefficient[exp] += coeff;
			if (exp == 0) {
				nPolynomial++; 
			}
			
		} while (nPolynomial <= 2);
		
		maxExp = coefficient.length - 1;
		while (coefficient[maxExp] == 0 && maxExp >0) {
			maxExp--;
		}
		
		if (maxExp != 0) {
			
			outputItem(coefficient[maxExp], maxExp, true);
			
			for (int i = maxExp - 1; i>0; i--) {
				if (coefficient[i] != 0) {
						outputItem(coefficient[i], i, false);
				}
			}
		
			System.out.printf("%+d",coefficient[0]);
			
		} else {
			System.out.print( coefficient[0]);
		}
		in.close();
	}

}
